package org.lhh.server.common.utils;

import java.util.ArrayList;
import java.util.List;

public class ImageUtil {

    public static int IMAGE_WIDTH = 40;

    public static int IMAGE_HEIGHT = 40;

    private static final String PREFIX = "http://localhost:9000/server/";

    private static List<String> pluginNames = new ArrayList<>();

    //有些插件的图片不是统一路径，需要自己适配
    static {
        pluginNames.add("BLKGP.svg");
        pluginNames.add("JSI.svg");
        pluginNames.add("JSO.svg");
    }

    public static String getURl(String imageFile) {
        if (pluginNames.contains(imageFile))
            return PREFIX + "ui/images/trans/" + imageFile;
        String prefix = imageFile.substring(0, imageFile.lastIndexOf("/"));
        String suffix = imageFile.substring(imageFile.lastIndexOf("/"));
        return PREFIX + prefix + "/trans" + suffix;
    }

    public static String getDBImage(String imageFile) {
        return PREFIX + "ui/images/databases/" + imageFile + ".svg";
    }
}
